/*
 * @Author: 赵成功a 3063126760@qq.com
 * @Date: 2024-12-21 20:13:51
 * @LastEditors: 赵成功a 3063126760@qq.com
 * @LastEditTime: 2024-12-26 00:25:44
 * @FilePath: /linux-learning/12-21/Client.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @Author: 赵成功a 3063126760@qq.com
 * @Date: 2024-12-21 20:13:51
 * @LastEditors: 赵成功a 3063126760@qq.com
 * @LastEditTime: 2024-12-25 23:53:17
 * @FilePath: /linux-learning/12-21/Client.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "comm.hpp"

#include "log.hpp"

int main()
{
    char s[1024];
    int fd = open(FIFO_FIFE, O_RDONLY); // 打开管道文件，以只读方式
    if (fd < 0)
    {
        perror("open failed");
        exit(FIFO_OPEN_ERR);
    }
    while (true)
    {
        int n = read(fd, &s, sizeof(s));
        if (n > 0)
        {
            s[n] = 0;
            cout << "Client read@";
            cout << s << endl;
        }
        else if (n == 0)
        {
            cout << "退出了";
            break;
        }
    }
    close(fd); // 关闭文件
}